#include "gather_task.h"
#include "stdio.h"
TaskHandle_t gatherHandler;


void init_gather()
{
    
    DHT11_Init();
    ADCx_Init();
    rainInit();
}

void gather_task(void* parm)
{		u16 value;
    while(1)
    {
        GatherData source;
			//读取dth11采集的数据
       /*
       u8 temp; u8 humi;
       DHT11_Read_Data(&temp,&humi);
       printf("read data: %d , %d \r\n",temp,humi);
        
        value=Get_ADC_Value(ADC_Channel_9,1);
        printf("检测AD值为：%d\r\n",value);
        value=100-value/40;
        if(value>=100)value=100;
         printf("read data: %d , %d \r\n",value);
       
         value=Get_ADC_Value(ADC_Channel_8,1);
        printf("检测AD值为：%d\r\n",value);
        value=value/40;
        if(value>=100)value=100;
         printf("read data: %d \r\n",value);
        printf("read data: %d \r\n",DATA_PIN_READ); */
         

        DHT11_Read_Data(&source.temp,&source.humi);
        // 光照
        source.sunshine=Get_ADC_Value(ADC_Channel_9,1);
        // 烟
        source.smoke=Get_ADC_Value(ADC_Channel_8,1);
        // 雨水
        source.raidrop=DATA_PIN_READ==0?0:1;
        dataHandler(&source);


        vTaskDelay(2000);
    }
}
// 创建心跳任务
void createGatherTask()
{
    xTaskCreate(gather_task,"gather_task",
        128,NULL,2,&gatherHandler);
}
